package com.mtw.bbs.article.controller.provide;


import com.mtw.bbs.article.pojo.vo.SimpleArticleVo;
import com.mtw.bbs.article.service.ArticleIndexService;
import com.mtw.bbs.common.core.vo.Result;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.List;



@RestController
@RequiredArgsConstructor
@RequestMapping("provide/article")
public class ArticleProvider {



    private final ArticleIndexService articleIndexService;



    /**
     * 根据id获取简单文章
     */
    @ApiOperation(value = "根据id获取简单文章", notes = "传入文章id集合")
    @PostMapping( "/getArticleById")
    public Result<List<SimpleArticleVo>> getArticleById(@RequestBody String[] ids){

        if (ids == null || ids.length < 1){
            return Result.fail("参数为空");
        }
        List<SimpleArticleVo> result = articleIndexService.getSimpleArticle(Arrays.stream(ids).toList());
        return Result.success(result);

    }





}
